<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Off the Record</title>   
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
</head>

<script type="text/javascript">
	function serach() {
		var f = document.searchForm;
		if(f.companyName.value==""){
			alert("회사명을 입력해주세요!");
			f.companyName.focus();
			return false;
		}
		f.submit();
		
	}
</script>
<body>
<c:import url="../common/top.jsp"></c:import>
<div class="container" style="margin: 60px;"></div>

<div class="container">
<div class="row">
<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div>

<div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<c:import url="admin_menu.jsp"/>
</div>
<!--  -->
<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">

	<!-- 탭 -->
	<div class="bs-example bs-example-tabs" role="tabpanel">
		<ul id="myTab" class="nav nav-tabs" role="tablist">
			<li role="presentation" class="active"><a href="#home" id="home-tab" role="tab" data-toggle="tab" aria-controls="home" aria-expanded="true">기업 검색/수정/삭제 <span class="glyphicon glyphicon-tower"></a></li>
	  	</ul>
	    
	    <div id="myTabContent" class="tab-content">
			<div role="tabpanel" class="tab-pane fade in active" id="home" aria-labelledBy="home-tab">
		   			
			<div class="user-update col-lg-12" style="padding: 10px;">
			<!--  -->
	<div class="user-id-search col-lg-12" style="background-color: lightgray; border: 1px solid lightgray; border-radius: 5px; padding: 10px;">
		<form class="form" role="form" name="searchForm" action="/OffTheRecord/getComapnyByCompanyName.action" onsubmit="serach(); return false;">
			<div class="input-group">
					<input list="companyName" class="form-control" placeholder="기업명을 입력해주세요." name="companyName" id="company_name">
					<datalist id="companyName">
						<c:forEach items="${clist }" var="clist">
							<option id="clist" value="${clist.companyName}">
						</c:forEach> </datalist>
					<span class="input-group-btn">
					<input type="submit" class="btn btn-default" id="SubmitBtn" value="검색"/>
					</span>
			</div>
		</form>
	</div>
	
	<div class="page-header">
		<hr>
	</div>

<!--  -->

      <div class="table-responsive">
        <table class="table table-hover">
        
          <thead>
          <c:if test="${fn:length(list) == 0}">
          	<tr><td> 검색하신 기업이 없습니다. </td></tr>
           </c:if>
          <c:if test="${fn:length(list) != 0}">
            <tr>
              <th>#</th>
              <th>기업 명</th>
              <th>수정</th>
              <th>삭제</th>
            </tr>
            </c:if>
          </thead>
          
          <tbody>
          	
          	
          	<c:forEach items="${requestScope.list }" var="list" varStatus="i">
          	<tr>
          		<td>${i.count}</td>
          		<td>${list.companyName }</td>
          		<td><button class="btn btn-default btn-sm" onclick="location.href='/OffTheRecord/getOneCompany.action?companyId=${list.companyId}'" >수정</button></td>
             	<td><button class="btn btn-default btn-sm" onclick="location.href='/OffTheRecord/deleteCompany.action?companyId=${list.companyId}&&companyName=${list.companyName }'">삭제</button></td>
             </tr>
          	</c:forEach>
          </tbody>
          
        </table>
      </div><!-- /.table-responsive -->






			<!--  -->
			</div>
						
			</div>
		</div>
	</div><!-- End 탭 -->
	

</div>
<!--  -->
</div>
<div class="col-xs-1 col-sm-1 col-md-1 col-lg-1"></div>
</div><!-- row -->
</div><!-- container -->

	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>   
</body>
</html>